import numpy as np
from matplotlib import pyplot as plt, animation

fig, ax = plt.subplots()
x_data, y_data = [], []

ln, = ax.plot([], [], animated=True)

ax.set_xlim(0, 2 * np.pi)
ax.set_ylim(-1, 1)

xdata = np.linspace(0, 2 * np.pi, 100)
ydata = np.sin(xdata)


def update(frame):
    ln.set_data(x_data[:frame], y_data[:frame])
    return ln


lin_ = animation.FuncAnimation(fig,
                               update,
                               frames=xdata.size,
                               interval=30,
                               blit=True,
                               repeat=False)

plt.show()
